package com.qf.shopping.service.impl;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.qf.shopping.dto.OperateLogDTO.OperateLogDTO;
import com.qf.shopping.mapper.IAdminMangerMapper;
import com.qf.shopping.mapper.message.OperateLogMapper;

import com.qf.shopping.pojo.System.User;
import com.qf.shopping.pojo.message.OperateLog;
import com.qf.shopping.service.IOperateLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author 82024
 * @Date 2019/4/19 23:35
 * @Version 1.0
 * @Description
 **/
@Service
@Transactional
public class OperateLogServiceImpl implements IOperateLogService {

    @Autowired
    private OperateLogMapper operateLogMapper = null;

    @Autowired
    private IAdminMangerMapper iAdminMangerMapper=null;

    @Override
    public List<OperateLogDTO> findAllOperateLog() {
        List<OperateLog> listLog=operateLogMapper.findAllOperateLog();
        List<OperateLogDTO> lists=new ArrayList<>();
        for (OperateLog log:listLog) {
            OperateLogDTO operateLogDTO=new OperateLogDTO(log);
             User user=iAdminMangerMapper.findUserById(log.getOperateUid());
            operateLogDTO.setOperateName(user.getUserName());
             lists.add(operateLogDTO);
        }
        return lists;
    }
}
